package com.edu.account.service.impl;

import com.edu.account.entity.TAccount;
import com.edu.account.mapper.TAccountMapper;
import com.edu.account.service.ITAccountService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author dingchengyu
 * @since 2022-05-13
 */
@Service
@Slf4j
public class TAccountServiceImpl extends ServiceImpl<TAccountMapper, TAccount> implements ITAccountService {

    @Override
    public Long deductAccount(Long userId, Long money) {
        log.info("[账户服务]>------>扣减账户开始");
        if (10000L == userId) {
            throw new RuntimeException("[账户服务]>------>扣减账户异常");
        }
        baseMapper.deductAccount(userId, money);
        log.info("[账户服务]>------>扣减账户结束");
        return money;
    }
}
